﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Order_Create.aspx.cs" Inherits="OrderManagement_Order_Create" MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>新建订单</title> 
    <script src="../JavaScript/common.js" type="text/javascript"></script>
    <script src="../JavaScript/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        function CheckReg(object) {
            var reg = /^\d{1,8}([.]{1}\d{1,4})?$/;
            if (!reg.exec(object.value)) {
                alert("格式错误！");
                object.value = "0.00";
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">

    function formatDate(v) {
        if (v instanceof Date) {
            var y = v.getFullYear();
            var m = v.getMonth() + 1;
            var d = v.getDate();
            var h = v.getHours();
            var i = v.getMinutes();
            var s = v.getSeconds();
            var ms = v.getMilliseconds();
            if (ms > 0)
                return y + '/' + m + '/' + d + ' ' + h + ':' + i + ':' + s
                        + '.' + ms;
            if (h > 0 || i > 0 || s > 0)
                return y + '/' + m + '/' + d + ' ' + h + ':' + i + ':' + s;
            return y + '/' + m + '/' + d;
        }
        return '';
    }

    $(function () {
        $('#<%=txtOrderDate.ClientID %>').datebox({
            currentText: '今天',
            closeText: '关闭',
            disabled: false,
            required: true,
            missingMessage: '必填',
            formatter: formatDate
        });
    });
    $(function () {
        $('#<%=txtDeliveryDate.ClientID %>').datebox({
            currentText: '今天',
            closeText: '关闭',
            disabled: false,
            required: true,
            missingMessage: '必填',
            formatter: formatDate
        });
    });

    function OpenWindow(pid,uid,cid) {

        openWindow('Product_Select.aspx?ValueControlId=' + pid + '&repID=' + uid + '&customerID=' + cid, '添加产品', 'location=no,scrollbars=1,width=900,height=600,left=0,top=0');
    }

</script>
    <div>
        <asp:Panel ID="pnlOrder" runat="server">
            <table id="wsd_inputtable">
                <tr>
                    <td colspan="6" class="tabletitle">
                        门店名称:<asp:Label runat="server" ID="lblCustomer"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td colspan="6"> 
                        <font color="red" size="2"><b>&nbsp;&nbsp; 提示:*为必选项! </b></font>

                    </td>
                </tr>
                <tr>
                    <td class="tablefield" valign="top">
                        <span class="keyword">*</span> 订单日期
                    </td>
                    <td nowrap="nowrap">
                        <asp:TextBox ID="txtOrderDate" runat="server"  class="default" ></asp:TextBox>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtOrderDate"
                            ErrorMessage="订单日期不能为空!"></asp:RequiredFieldValidator>
                        <br />
                        <asp:RangeValidator ID="rv1" runat="server" ControlToValidate="txtOrderDate" ErrorMessage="订单日期不能大于今天或小于本月"></asp:RangeValidator>
                    </td>
                    <td class="tablefield" valign=top  >
                        <span class="keyword">*</span> 订单来源
                    </td>
                    <td nowrap="nowrap" id="tdOrderForm" runat="server" valign="top">
                        <asp:DropDownList ID="ddlOrderForm" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlOrderForm_SelectedIndexChanged">
                        </asp:DropDownList>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlOrderForm"
                            ErrorMessage="订单来源不能为空!" ></asp:RequiredFieldValidator>
                        <br />
                    </td>
                    <td class="tablefield" valign="top">
                        <span class="keyword">*</span>请求发货日期
                    </td>
                    <td nowrap="nowrap">
                        <asp:TextBox ID="txtDeliveryDate" runat="server"  class="default"></asp:TextBox>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDeliveryDate"
                            ErrorMessage="请求发货日期不能为空!" ></asp:RequiredFieldValidator>
                        <br />
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtOrderDate"
                            ControlToValidate="txtDeliveryDate" ErrorMessage="请求发货日期不能小于订单日期!" Operator="GreaterThanEqual"
                            Type="Date"> </asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td class="tablefield">
                        <%--<span class="keyword">*</span> --%>经销商
                    </td>
                    <td nowrap="nowrap">
                        <asp:DropDownList runat="server" ID="ddlChains" AutoPostBack="True" OnSelectedIndexChanged="ddlChains_SelectedIndexChanged">
                        </asp:DropDownList>
                        <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="经销商不能为空"
                            Text="*" ControlToValidate="ddlChains"></asp:RequiredFieldValidator>--%>
                    </td>
                    <td class="tablefield">
                      <%-- 供应商--%>
                    </td>
                    <td nowrap="nowrap">
                        <asp:Label ID="lblSupply" runat="server"></asp:Label>
                    </td>
                    <td class="tablefield" valign=top>
                        &nbsp;</td>
                    <td align="left">
                        <br />
                    </td>
                </tr>
             
            </table>
            <table id="wsd_inputtable">
                <tr>
                    <td width="100%" class="tabletitle">
                        产品列表
                    </td>
                </tr>
            </table>
            <table id="wsd_listtable">
                <tr>
                    <td>
                        <asp:GridView Width="100%" ID="gvProductList" runat="server" AutoGenerateColumns="false"
                            EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                            DataKeyNames="ID" HtmlEncode="false" EnableEmptyContentRender="true" AllowPaging="False"
                            OnRowDeleting="gvProductList_RowDeleting" OnRowCommand="gvProductList_RowCommand"
                            OnRowDataBound="gvProductList_RowDataBound">
                            <HeaderStyle CssClass="titlist" />
                            <EmptyDataRowStyle Font-Bold="True" HorizontalAlign="Center" />
                            <Columns>
                                <asp:BoundField HeaderText="产品代码" DataField="CODE" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="产品名称" DataField="DESCRIPTION" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="制造商" DataField="MANUFACTURE" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="品类" DataField="CATEGORY" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="品牌" DataField="BRAND" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="系列" DataField="FORM" HeaderStyle-HorizontalAlign="Center" />
                                <asp:TemplateField HeaderText="数量" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:TextBox runat="server" ID="txtOrderPC" MaxLength="8" size="9" Text='<%# Eval("ORDER_PC") %>'></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtOrderPC"
                                            ValidationExpression="^[1-9]\d*$" ErrorMessage="请输入数值" Text="请输入数值" runat="server" Display="Dynamic"></asp:RegularExpressionValidator>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <%--                <asp:TemplateField HeaderText="订箱">
                                    <ItemTemplate>
                                        <asp:TextBox runat="server" ID="txtOrderCase" MaxLength="8" size="9" Text='<%# Eval("ORDER_CASE") %>'></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ControlToValidate="txtOrderCase"
                                            ValidationExpression="^[1-9]\d*$" ErrorMessage="请输入数值" Text="*" runat="server"></asp:RegularExpressionValidator>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="退瓶">
                                    <ItemTemplate>
                                        <asp:TextBox runat="server" ID="txtReturnPC" MaxLength="8" size="9" Text='<%# Eval("RETURN_PC") %>'></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" ControlToValidate="txtReturnPC"
                                            ValidationExpression="^[1-9]\d*$" ErrorMessage="请输入数值" Text="*" runat="server"></asp:RegularExpressionValidator>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="换瓶">
                                    <ItemTemplate>
                                        <asp:TextBox runat="server" ID="txtChangePC" MaxLength="8" size="9" Text='<%# Eval("CHANGE_PC") %>'></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" ControlToValidate="txtChangePC"
                                            ValidationExpression="^[1-9]\d*$" ErrorMessage="请输入数值" Text="*" runat="server"></asp:RegularExpressionValidator>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Button ID="btnPromotion" CssClass="btn3_mouseover" CommandName="promotion" runat="server"
                                            Text="促销" CausesValidation="false" CommandArgument='<%# Eval("ID") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>--%>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton1" Text="删  除" CausesValidation="false" runat="server"
                                            CommandName="delete" OnClientClick="return confirm('您真的要删除吗，此操作不可逆');"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <PagerSettings FirstPageText="首页" LastPageText="尾页" Mode="NumericFirstLast" PageButtonCount="30" />
                            <RowStyle CssClass="evenline" />
                            <AlternatingRowStyle CssClass="oddline" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
            <table id="wsd_inputtable">
                <tr>
                    <td width="100%" class="tabletitle">
                        <asp:Literal ID="Literal15" runat="server" Text="操作区域"></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td class="buttonarea">
                        <asp:Button ID="btnAddProduct" runat="server" class="wsd_button2" Text="添加产品" OnClick="btnAddProduct_Click" CausesValidation="false"  />
                        <%--<input id="btnAddProduct" type="button" class="wsd_button2" value="添加产品" onclick="openWindow('Product_Select.aspx?ValueControlId=txtHidProduct','')" />--%>
                        &nbsp;&nbsp;<asp:Button ID="btnSave" runat="server" class="wsd_button2" Text="下一步"
                            OnClick="btnSave_Click" />&nbsp;&nbsp;
                        <input id="btnCancel" type="button" class="wsd_button2" value="返  回" onclick="location.href='Customer_Select.aspx'" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <asp:Panel ID="pnlConfirm" runat="server" Visible="false">
            <table id="wsd_inputtable">
                <tr>
                    <td colspan="6" class="tabletitle">
                        门店名称 :<asp:Label ID="lblCustomer2" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                 
                        <font color="red" size="2"><b>请您仔细确认您的订单<br />
                        </b></font>&nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="tablefield" style="width: 124px">
                        经销商:
                    </td>
                    <td nowrap="nowrap" class="style1">
                        <asp:Label ID="lblChain" runat="server"></asp:Label>
                    </td>
                    <td class="tablefield" style="width: 112px">
                        订单日期:
                    </td>
                    <td nowrap="nowrap" class="style2">
                        <asp:Label ID="lblOrderDateConfirm" runat="server"></asp:Label>
                    </td>
                    <td class="tablefield" >
                        业务员:
                    </td>
                    <td nowrap="nowrap">
                        <asp:Label ID="lblUser" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="tablefield" style="width: 124px">
                        供应商:
                    </td>
                    <td nowrap="nowrap" class="style1">
                        <asp:Label ID="lblSupply2" runat="server"></asp:Label>
                    </td>
                    <td class="tablefield" style="width: 112px">
                        发货日期:
                    </td>
                    <td nowrap="nowrap" class="style2">
                        <asp:Label ID="lblRdd" runat="server"></asp:Label>
                    </td>
                    <td class="tablefield" >
                        订单总数:</td>
                    <td >
                        <asp:Label ID="lblTotalPcOrder" runat="server"></asp:Label>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="tablefield" style="width: 112px">
                        &nbsp;</td>
                    <td nowrap="nowrap" class="style2">
                        &nbsp;</td>
                    <td class="tablefield" style="width: 112px">
                    </td>
                    <td nowrap="nowrap" class="style2">
                    </td>
                    <td class="tablefield">
                    </td>
                    <td nowrap="nowrap" class="style2">
                    </td>
                 
                </tr>
              
            </table>
            <br />
            <table id="wsd_inputtable">
                <tr>
                    <td width="100%" class="tabletitle">
                        订单明细
                    </td>
                </tr>
            </table>
            <table id="wsd_listtable">
                <tr>
                    <td>
                        <asp:GridView Width="100%" ID="gvOrderList" runat="server" AutoGenerateColumns="false"
                            EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                            DataKeyNames="ID" HtmlEncode="false" EnableEmptyContentRender="true" AllowPaging="False"
                            OnRowDataBound="gvOrderList_RowDataBound">
                            <HeaderStyle CssClass="titlist" />
                            <EmptyDataRowStyle Font-Bold="True" HorizontalAlign="Center" />
                            <Columns>
                                <asp:BoundField HeaderText="产品名称" DataField="NAME" HeaderStyle-HorizontalAlign="Center">
                                </asp:BoundField>
                                <asp:BoundField HeaderText="规格" DataField="UOM" HeaderStyle-HorizontalAlign="Center">
                                </asp:BoundField>
                                <asp:BoundField HeaderText="制造商" DataField="MANUFACTURE" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="品类" DataField="CATEGORY" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="品牌" DataField="BRAND" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="系列" DataField="FORM" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="单价" DataField="PIECEPRICE" HeaderStyle-HorizontalAlign="Center" />
                                <asp:BoundField HeaderText="数量" DataField="QTY" HeaderStyle-HorizontalAlign="Center">
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="收货单价" HeaderStyle-HorizontalAlign="Center" Visible="false">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtAmount" runat="server" MaxLength="15" size="10" Text="0.00" onchange="CheckReg(this)"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="收货日期" HeaderStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtRecevieDate" runat="server" CssClass="Wdate" onfocus="WdatePicker()"
                                            size="15"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <HeaderTemplate>
                                        <asp:CheckBox runat="server" ID="cbxAllSelected" AutoPostBack=true  OnCheckedChanged ="SelectALL" />
                                        全选
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox runat="server" ID="cbxSelected" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <RowStyle CssClass="evenline" />
                            <AlternatingRowStyle CssClass="oddline" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
            <br />
     
            <table id="wsd_inputtable">
                <tr>
                    <td width="100%" class="tabletitle">
                        <asp:Literal ID="Literal1" runat="server" Text="操作区域"></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td class="buttonarea">
                        <asp:Button ID="btnConfirm" runat="server" CausesValidation="false" UseSubmitBehavior="false"
                            class="wsd_button2" Text="生成订单" OnClick="btnConfirm_Click" OnClientClick="return HaveCheck('cbxSelected', '没有选择任何项');"  />&nbsp;&nbsp;
                        <asp:Button ID="btn" runat="server" CausesValidation="false" UseSubmitBehavior="false"
                            class="wsd_button2" Text="生成并确认" OnClick="btn_Click" Visible="False" />
                        &nbsp;&nbsp;
                        <input id="Button1" type="button" value="修  改" class="wsd_button2" onclick="history.back()" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
    <asp:HiddenField ID="txtHidProduct" runat="server" OnValueChanged="txtHidProduct_ValueChanged" />
    <asp:HiddenField ID="txtHidFreeGoods" runat="server" OnValueChanged="txtHidFreeGoods_ValueChanged" />
</asp:Content>
